package org.example.library_management_system.Config;

import lombok.extern.slf4j.Slf4j;
import org.example.library_management_system.Model.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

//统一异常处理

@Slf4j
@ControllerAdvice
@ResponseBody
public class ExceptionAdvice {


    @ExceptionHandler
    public Object handel(Exception e){
        log.error("出现的异常：",e);
        return Result.fail(e.getMessage());
    }

}
